/**
 *  Github Resource:
 *      - https://github.com/dpilger26/NumCpp
 *  Depend:
 *      1. sudo apt install libboost1.83-all-dev
 *
 *  Only Work in 2D
 *
 * time record:
    double start, end;
    double elapsed;
    start = (double) clock();
    end = (double )clock();
    elapsed = (end - start) / CLOCKS_PER_SEC / 10;  // bug
    qDebug() << "Time cost: " << elapsed << "s";
 */
#include <opencv2/opencv.hpp>
#include "NumCpp.hpp"

cv::Mat preprocessSampleInput(){
    std::string sampleImage = "../../../resource/raw_resize/1.jpg";
    cv::Mat mat = cv::imread(sampleImage);

//    qDebug() << "Mat basic Info" << mat.rows << mat.cols << mat.dims;
    if(mat.rows != 512 && mat.cols != 512){
        cv::resize(mat, mat, cv::Size(512, 512));
    }

    mat.convertTo(mat, CV_32F);
    cv::Scalar matMean; cv::Mat matStd;
    cv::meanStdDev(mat, matMean, matStd);
    matStd += 1e-8;
    double *stdPtr = matStd.ptr<double>();
    cv::Scalar stdScalar(*(stdPtr + 0), *(stdPtr + 1), *(stdPtr + 2));

    cv::subtract(mat, matMean, mat);
    mat /= stdScalar;

//    return cv::dnn::blobFromImage(mat);
    return mat;
}


int main(int argc, char *argv[])
{
    nc::NdArray<int> a = nc::arange(8);
    std::cout << a.reshape(4, 2);
}
